/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.gpstracking.DA;

import java.util.List;

import com.gpstracking.BE.*;


import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

/**
 *
 * @author jmj
 */
public class EventoDA {


    public synchronized static void save(Evento evento) {
        Session hbsession = HUtil.getSession();
        Transaction tx = hbsession.beginTransaction();
        tx.begin();
        try{
            
            hbsession.save(evento);
         
            tx.commit();
            
            
        }catch(Exception ex){
            ex.printStackTrace();
            tx.rollback();
            
            
        }
        
      
        
    }

	public static List<Evento> getEventos() {
		 Session hbsession = HUtil.getSession();
		 Transaction tx = hbsession.beginTransaction();
		tx.begin();
        Query query = hbsession.createQuery("FROM Evento");
        List<Evento> res = (List<Evento>) query.list();
        
        return res;
	}
    
}
